forum

home / developersection / forums / does finally always execute in java?

Does finally always execute in Java?

Anonymous User 1895 08-May-2015
I have a try/catch block with returns inside it. Will the finally block be called?

For example:

try {  
    something();  
    return success;  
}  
catch (Exception e) {   
    return failure;  
}  
finally {  
    System.out.println("i don't know if this will get printed out.");
}
I know I can just type this in an see what happens (which is what I'm about to do, actually) but when I googled for answers nothing came up, so I figured I'd throw this up as a question.

Updated on 08-May-2015

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By